package com.hackerrank.www.datastructures;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * Created by 27340 on 2017/5/6.
 */
public class AlgCrush {
    static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer tok = null;

    public static void main(String[] args) {
        int n = getInt();
        int m = getInt();
        long[] array = new long[n];
        long max = 0;
        for(int i=0;i<m;i++){
            int a = getInt();
            int b = getInt();
            long k = getLong();
            for(int index=a-1;index<=b-1;index++){
                array[index] = array[index] + k;
                if(max<array[index]){
                    max = array[index];
                }
            }
        }
        Arrays.sort(array);
        System.out.println(max);
    }
    static String gets() throws IOException {
        if(tok == null || !tok.hasMoreTokens())
            tok = new StringTokenizer(br.readLine());
        return tok.nextToken();
    }

    static int getInt() {
        try {
            return Integer.parseInt(gets());
        } catch(IOException | NumberFormatException e) {
            return -1;
        }
    }

    static long getLong() {
        try {
            return Long.parseLong(gets());
        } catch(IOException | NumberFormatException e) {
            return -1;
        }
    }
}
